package com.foreknow.tijian.controller;

import com.foreknow.tijian.po.User;
import com.foreknow.tijian.service.UserService;
import com.foreknow.tijian.service.Impl.UserServiceImpl;

import javax.servlet.http.HttpServletRequest;

public class UserController {
    public Object saveUser(HttpServletRequest request) {
        UserService userService = new UserServiceImpl();
        User user = new User();
        user.setUserId(request.getParameter("userId"));
        user.setUserName(request.getParameter("userName"));
        user.setPassword(request.getParameter("password"));
        user.setUserSex(Integer.parseInt(request.getParameter("userSex")));
        int result = userService.saveUser(user);
        return result;
    }
    //http://localhost:8080/elm/UserController/getUserById?orderTypeId=12345
    public Object getUserById(HttpServletRequest request) {
        UserService userService = new UserServiceImpl();
        String userId = request.getParameter("userId");
        int count=userService.getUserById(userId);
        return count;
    }

    //http://localhost:8080/elm/UserController/getUserByIdByPass?userId=8080&password=1
    public Object getUserByIdByPass(HttpServletRequest request) {
        UserService userService = new UserServiceImpl();
       User user = new User();
       String userId = request.getParameter("userId");
       String password = request.getParameter("password");
       user=userService.getUserByIdByPass(userId,password);
       return user;
    }
}
